package com.example.stringbufferlogger.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.stringbufferlogger.entity.FileConfig;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface FileConfigMapper extends BaseMapper<FileConfig> {

    /**
     * 根据 requestid 查询 file_config 表中的 file_type
     * @param requestid 请求 ID
     * @return 文件类型
     */
    @Select("SELECT c.file_type FROM file_config c WHERE c.interface_adrs = (" +
            "SELECT b.new_path FROM INTERFACE_MAPPING_CONFIG b WHERE b.old_path = (" +
            "SELECT a.path FROM replay_log a WHERE a.requestid = #{requestid} AND ROWNUM = 1) AND ROWNUM = 1) AND ROWNUM = 1")
    String selectFileTypeByRequestId(@Param("requestid") String requestid);

}
